package com.db.bankapp.domain.bank;

/**
 * @Not-ThreadSafe
 * Base implementation of @link{com.db.bankapp.domain.bank.Account}
 */
abstract class AccountBase implements Account {
    protected int balance;

    @Override
    public int getBalance() {
        return balance;
    }

    @Override
    public void deposit(int amount) {
        this.balance += amount;
    }

    @Override
    public void withdraw(int amount) {
        if (balance < amount) {
            throw new IllegalArgumentException("Not enough money");
        }
        balance -= amount;
    }

    @Override
    public int maximumAmountToWithdraw() {
        return balance;
    }
}

